package com.shujia.day17.lambda1;

import java.util.ArrayList;

public class Operator {
    public static void main(String[] args) {
        /*
            需求：对于4个员工，过滤出薪资小于等于 8000 员工
         */
        ArrayList<Staff> staffs = new ArrayList<>();
        staffs.add(new Staff("易政", 18, 12000));
        staffs.add(new Staff("李国涛", 19, 20000));
        staffs.add(new Staff("刘俊杰", 13, 8000));
        staffs.add(new Staff("陆玉龙", 12, 6000));

        System.out.println(filter(staffs,8000));
    }

    public static ArrayList<Staff> filter(ArrayList<Staff> staffs,int salary){
        ArrayList<Staff> lessStaff = new ArrayList<>();
        for (Staff staff : staffs) {
            if (staff.salary <= salary){
                lessStaff.add(staff);
            }
        }
        return lessStaff;
    }

}
